<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function init(){
	document.querySelector("#username").addEventListener("blur",()=>{
		let xhr=new XMLHttpRequest();
		let url="login.Servlet?param=checkname&username="+document.querySelector("#username").value;
		xhr.responseType="json";
		xhr.open("get",url,true);
		
		xhr.addEventListener("readystatechange",()=>{
			if(xhr.readyState==4 && xhr.status==200){
				let json=xhr.response;
				if(json.result=="ok"){
					console.log(json.name);
					
				}
			}
		},false);
		xhr.send(null);
	},false);
	
}
window.addEventListener("load",init,false);
</script>
</head>
<body>
<form action="login.Servlet?param=login" method="post">
用户名：<input type="text" name="username" id="username"> <br>
密码：<input type="password" name="password"> <br>
<input type="checkbox" value="yes" name="isCookie">一天之内不再登录<br>
<button type="submit">登录</button>
<button type="submit" formaction="login.Servlet?param=register">注册</button>
</form>
</body>
</html>